<?php
$cs=Yii::app()->clientScript;
$cs->registerScript('consignee_info',<<<END
function make_name(info){\$(info).each(function(i,item){\$(item).find("input[type!=button],textarea").each(function(n,obj){var re=/\d{1,10}/g;obj.name=obj.name.replace(re,String(i));});});}
var info_n=100;function info(main,info,add_btn,del_btn){this.main=main;this.info=info;this.init=function(){\$(add_btn).click(this.add_info);$(del_btn).click(this.del_info);}
this.add_info=function(){info_n+=1
var f=$(".linkman_info_temp:first").clone(true);f.attr('class','linkman_info').show();f.find("input[type!=button],textarea").val('').removeClass('error').each(function(i,obj){var re=/\d{1,10}/g;obj.id=obj.id.replace(re,info_n);});f.find("span[class=error]").remove();f.appendTo(main);make_name(info);}
this.del_info=function(){\$(this).parents(info).remove();make_name(info);}}
var t=new info("#main",".linkman_info","#add_linkman",'.del_linkman');t.init();
END
);
?>
<div class="yiiForm">
<?php
	echo EHtml::form();	
	EHtml::setOptions(array('errorElement'=> 'span',));		
?>
<div>注：<span class="required">*</span>为必填项</div>
<div id="leftaa">
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'name'); ?>
<?php echo EHtml::activeTextField($model,'name',array('size'=>20,'maxlength'=>100)); ?>
</div>
<div class="simple1"  style="margin-bottom:-1px;">
<?php echo CHtml::activeLabelEx($model,'office_tel'); ?>
<?php echo EHtml::activeTextField($model,'office_tel',array('size'=>20,'maxlength'=>25)); ?>
</div>
</div>
  <div id="rightaa">
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'office_fax'); ?>
<?php echo EHtml::activeTextField($model,'office_fax',array('size'=>20,'maxlength'=>25)); ?>
</div>
<div class="simple1"  style="margin-bottom:-1px;">
</div>
</div>
<div style="border:1px solid #90b3bc;border-top:0px;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="add_linkman" type="button" value="添加卸货地"/>
</div>

<div id="main">
<?php
	foreach($linkman_models as $n=>$linkman_model):
?>
<table class="linkman_info" width="100%"   border="0"   cellpadding="0"   cellspacing="0"   bgcolor="#90b3bc">
<tr>
<td width="122"  bgcolor="#ffffff" align="right" height="30"><?php echo CHtml::activeLabelEx($linkman_model,'name'); ?></td>
<td  bgcolor="#ffffff">&nbsp;&nbsp;<?php echo EHtml::activeTextField($linkman_model,'name',array('class'=>'required','name'=>"linkman[{$n}][name]",'size'=>8,'maxlength'=>11)); ?></td>
<td bgcolor="#ffffff" align="right" height="30"><?php echo CHtml::activeLabelEx($linkman_model,'mobile_no'); ?></td>
<td  bgcolor="#ffffff">&nbsp;&nbsp;<?php echo EHtml::activeTextField($linkman_model,'mobile_no',array('class'=>'required','name'=>"linkman[{$n}][mobile_no]",'size'=>20,'maxlength'=>18)); ?></td>
</tr>
<tr>
<td bgcolor="#ebf4fb" align="right" height="30"><?php echo CHtml::activeLabelEx($linkman_model,'addr'); ?></td>
<td  bgcolor="#ebf4fb">&nbsp;&nbsp;<?php echo EHtml::activeTextField($linkman_model,'addr',array('class'=>'required','name'=>"linkman[{$n}][addr]",'size'=>45,'maxlength'=>100)); ?></td>
<td   bgcolor="#ebf4fb"></td>
<td   bgcolor="#ebf4fb"></td>
</tr>
<tr>
<td  bgcolor="#ebf4fb"  height="120"align="right"><?php echo CHtml::activeLabelEx($linkman_model,'rule'); ?></td>
<td  colspan="3" bgcolor="#ebf4fb">&nbsp;&nbsp;<?php echo EHtml::activeTextArea($linkman_model,'rule',array('rows'=>6, 'cols'=>45 ,'name'=>"linkman[{$n}][rule]",'maxlength'=>300)); ?>&nbsp;&nbsp;&nbsp;&nbsp;<input class="del_linkman"  type="button" value="删除"/></td>
</tr>
<tr><td colspan="4" bgcolor="#90b3bc" height="1" ></tr>
</table><!--linkman_info-->
<?php 
endforeach;
?>
</div><!-- main -->

<div class="action">
<?php echo EHtml::submitButton($update ? '更新信息' : '添加信息'); ?>
</div>
<?php echo EHtml::endForm(); ?>
</div><!-- yiiForm -->
<table class="linkman_info_temp" style="display:none" width="100%"   border="0"   cellpadding="0"   cellspacing="0"   bgcolor="#90b3bc">
<tr>
<td width="122"  bgcolor="#ffffff" align="right" height="30"><?php echo CHtml::activeLabelEx($linkman_model_temp,'name'); ?></td>
<td  bgcolor="#ffffff">&nbsp;&nbsp;<?php echo EHtml::activeTextField($linkman_model_temp,'name',array('class'=>'required','name'=>"linkman[0][name]",'size'=>8,'maxlength'=>11)); ?></td>
<td bgcolor="#ffffff" align="right" height="30"><?php echo CHtml::activeLabelEx($linkman_model_temp,'mobile_no'); ?></td>
<td  bgcolor="#ffffff">&nbsp;&nbsp;<?php echo EHtml::activeTextField($linkman_model_temp,'mobile_no',array('class'=>'required','name'=>"linkman[0][mobile_no]",'size'=>20,'maxlength'=>18)); ?></td>
</tr>
<tr>
<td bgcolor="#ebf4fb" align="right" height="30"><?php echo CHtml::activeLabelEx($linkman_model_temp,'addr'); ?></td>
<td  bgcolor="#ebf4fb">&nbsp;&nbsp;<?php echo EHtml::activeTextField($linkman_model_temp,'addr',array('class'=>'required','name'=>"linkman[0][addr]",'size'=>45,'maxlength'=>100)); ?></td>
<td   bgcolor="#ebf4fb"></td>
<td   bgcolor="#ebf4fb"></td>
</tr>
<tr>
<td  bgcolor="#ebf4fb"  height="120"align="right"><?php echo CHtml::activeLabelEx($linkman_model_temp,'rule'); ?></td>
<td  colspan="3" bgcolor="#ebf4fb">&nbsp;&nbsp;<?php echo EHtml::activeTextArea($linkman_model_temp,'rule',array('rows'=>6, 'cols'=>45 ,'name'=>"linkman[0][rule]",'maxlength'=>300)); ?>&nbsp;&nbsp;&nbsp;&nbsp;<input class="del_linkman"  type="button" value="删除"/></td>
</tr>
<tr><td colspan="4" bgcolor="#90b3bc" height="1" ></tr>
</table><!--linkman_info-->
<?php 
if($model->hasErrors()) echo "<script>alert('您填写的信息有误！请根据页面红色图标提示修改。');</script>";
?>